package com.soft.admin.web;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.soft.admin.service.ActionService;
import com.soft.model.Action;
import com.soft.support.PageParam;

@Controller
@RequestMapping(value = "/admin/action.do")
public class ActionController extends BaseController {
	private ActionService actionService;
	
	@RequestMapping(params = "index")
	public String get(HttpServletResponse response, HttpServletRequest request, Action params, 
			PageParam page) throws IOException {
		String res = this.actionService.get(params, page);
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "add")
	public String add(HttpServletResponse response, HttpServletRequest request, Action params) 
			throws IOException {
		String res = this.actionService.addOrEdit(params);
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "edit")
	public String eidt(HttpServletResponse response, HttpServletRequest request, Action params) 
			throws IOException {
		String res = this.actionService.addOrEdit(params);
		response.getWriter().print(res);
		return null;
	}
	
	@RequestMapping(params = "remove")
	public String remove(HttpServletResponse response, HttpServletRequest request, Action params) 
			throws IOException {
		String res = this.actionService.remove(params);
		response.getWriter().print(res);
		return null;
	}
	
	@Resource
	public void setActionService(ActionService actionService) {
		this.actionService = actionService;
	}
}
